package util;

import org.jasypt.util.password.BasicPasswordEncryptor;

public class Crypto {

	public static String encrypt(String input) {
		BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
		String encrypted =  "+";

		while (encrypted.contains("+") || encrypted.contains("&") || encrypted.contains(" ") ){
			encrypted = passwordEncryptor.encryptPassword(input);
		}

		return encrypted;
	}

	public static boolean check(String input, String encrypted) {
		BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
		if (passwordEncryptor.checkPassword(input, encrypted)) {
			return true;
		} else {
			return false;
		}
	}

}
